import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: '/layout',
    },
    {
        path: '/login',
        name: 'login',
        component: () =>
            import ('../views/Login.vue')
    },
    {
        path: '/layout',
        name: 'layout',
        component: () =>
            import ('../views/layout/Index.vue'),

        children: [{
            path: '/index',
            name: 'index',
            component: require('../views/layout/home/Index.vue').default,
        }, {
            path: '/stats',
            name: 'stats',
            component: require('../views/layout/stats/Index.vue').default,
        }, {
            path: '/wms',
            name: 'stats',
            component: require('../views/layout/wms/Index.vue').default,
            children: [{
                path: '/wms/list',
                name: 'lessionDemo1',
                component: require('../views/layout/wms/List.vue').default,
            }]
        }, {
            path: '/user',
            name: 'user',
            component: require('../views/layout/user/Index.vue').default,
            children: [{
                path: '/user/stats',
                name: 'userStats',
                component: require('../views/layout/user/Stats.vue').default,
            }, {
                path: '/user/role',
                name: 'userRole',
                component: require('../views/layout/user/Role.vue').default,
            }]
        }, {
            path: '/lession',
            name: 'lession',
            component: require('../views/layout/lession/Index.vue').default,
            children: [{
                path: '/lession/demo1',
                name: 'lessionDemo1',
                component: require('../views/layout/lession/Demo1.vue').default,
            }, {
                path: '/lession/demo2',
                name: 'lessionDemo2',
                component: require('../views/layout/lession/Demo2.vue').default,
            }]
        }]
    }
]

const router = new VueRouter({
    routes
})

// router.beforeEach(function(to, from, next) {
//     if (!sessionStorage.getItem('username')) {
//         if (to.path !== '/login') {
//             next('/login')
//         }
//     }
//     next();
// })


// router.beforeResolve(function(to,from,next){

// })


export default router